﻿Public Class FEELING
    Dim connect As CONDB = CONDB.NewConnection()
    'Dim connectlocal As conlocal = conlocal.NewConnection

    Dim PROVIDER_MASFEELING As New PROVIDERSCLASS

    Private Sub FEELING_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        SelectDatagridfeeling()

        DesignForm(Me)
        DesignGrid(MASFEELINGGrid)

        PROVIDER_MASFEELING.GETHOSEM(CInt(main.txtUserRequest.Text.Trim), Convert.ToString(Me.Tag))
    End Sub

    Private Sub SelectDatagridfeeling()
        Dim objSelectDatamasfeeling As New masfeeling
        Dim MASFEELING As DataTable
        MASFEELING = connect.GetTable(objSelectDatamasfeeling.selectMasfeeling_)
        MASFEELINGGrid.PrimaryGrid.DataSource = MASFEELING
    End Sub

    Private Sub MASFEELINGGrid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles MASFEELINGGrid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสอารมณ์").Value() IsNot DBNull.Value Then
            FEELINGIDTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสอารมณ์").Value()
        Else
            FEELINGIDTxt.Text = ""
        End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ภาวะอารมณ์").Value() IsNot DBNull.Value Then
            FEELLINGTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ภาวะอารมณ์").Value()
        Else
            FEELLINGTxt.Text = ""
        End If
        addFeeling.Enabled = False
    End Sub

    Private Sub addFeeling_Click(sender As Object, e As EventArgs) Handles addFeeling.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_MASFEELING.PADD_ = True Then
                Dim objInsertData As New masfeeling
                objInsertData.feelING_ = FEELLINGTxt.Text
                objInsertData.insertMasfeelingData()

                SelectDatagridfeeling()

                FEELLINGTxt.Text = ""
            Else
                MsgBox(PROVIDER_MASFEELING.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub editFeeling_Click(sender As Object, e As EventArgs) Handles editFeeling.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_MASFEELING.PUPD_ = True Then
                Dim editStat As Integer
                editStat = MsgBox("ท่านต้องการแก้ไขข้อมูลดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                If editStat = 1 Then
                    Dim objEditData As New masfeeling
                    objEditData.feelID_ = FEELINGIDTxt.Text
                    objEditData.feelING_ = FEELLINGTxt.Text
                    objEditData.editMasfeelingData()

                    SelectDatagridfeeling()

                    FEELLINGTxt.Text = ""
                End If
                addFeeling.Enabled = True
            Else
                MsgBox(PROVIDER_MASFEELING.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub importExel_Click(sender As Object, e As EventArgs) Handles importExel.Click
        Dim nextform As New IMPORTEXCEL(masfeeling.Text)
        nextform.ShowDialog()
    End Sub

    Private Sub ButtonItem1_Click(sender As Object, e As EventArgs) Handles ButtonItem1.Click
        Dim nextform As New IMPORTEXCEL(masfeeling.Text)
        nextform.ShowDialog()
    End Sub

   
End Class